package com.azxc.rapid.plus.resource.feign;


import com.azxc.rapid.core.oss.model.RapidFile;
import com.azxc.rapid.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(
	value = "rapid-core-plus",
	fallback = IAttachPlusClientFallback.class
)
public interface IAttachPlusClient {

	String API_PREFIX = "/client-plus";
	String REMOVE_FILE_BY_NAME = API_PREFIX + "/remove-file-by-name";
	String REMOVE_FILE_BY_ID = API_PREFIX + "/remove-file-by-id";
	String REMOVE_FILE_BY_LINK = API_PREFIX + "/remove-file-by-link";
	String UN_LOGIN_PUTFILE = API_PREFIX + "/un-login-put-attach";

	String UN_LOGIN_PUTFILE_REPLACE = API_PREFIX + "/un-login-put-attach-replace";
	String PUT_BASE64 = API_PREFIX + "/put-base64";
	String PUT_BASE64_REPLACE = API_PREFIX + "/put-base64-replace";

	@PostMapping(value=UN_LOGIN_PUTFILE,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	R<RapidFile> unLoginPutFile(@RequestPart("file") MultipartFile file);

	@PostMapping(value=UN_LOGIN_PUTFILE_REPLACE,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	R<RapidFile> unLoginPutFileReplace(@RequestPart("file") MultipartFile file,@RequestParam("replace")boolean replace);


	@GetMapping(value = PUT_BASE64_REPLACE)
	R<RapidFile> putBase64Replace(@RequestParam("fileName") String fileName,@RequestParam("key") String key,@RequestParam("replace")boolean replace);

	@GetMapping(value = PUT_BASE64)
	R<RapidFile> putBase64(@RequestParam("fileName") String fileName,@RequestParam("key") String key);

	@GetMapping(value = REMOVE_FILE_BY_NAME)
	R removeFileByName(@RequestParam("fileName")String fileName);

	@GetMapping(value = REMOVE_FILE_BY_ID)
	R removeFileById(@RequestParam("attachId") Long attachId);

	@GetMapping(value = REMOVE_FILE_BY_LINK)
	R removeFileByLink(@RequestParam("link") String link);
}
